//
// Created by Tony on 2024/5/25.
//

#ifndef PARSER_PARAMETER_LIST_H
#define PARSER_PARAMETER_LIST_H

#include "../../AstList.h"
#include "../../leaf/Name.h"
#include "../TypeTag.h"
#include <cstdint>

namespace Parser {

class ParameterList final : public AstList {
    string nodeName;
    vector<int32_t> types;

public:
    ParameterList() : AstList({}) { nodeName = __func__; }

    explicit ParameterList(const vector<shared_ptr<Ast>>& children) : AstList(children) {
        nodeName = __func__;
    }

    uint16_t size() { return children.size(); }

    shared_ptr<Name> name(uint16_t index) {
        return static_pointer_cast<Name>(children[index << 1]);
    }

    shared_ptr<TypeTag> typeTag(uint16_t index) {
        return static_pointer_cast<TypeTag>(children[(index << 1) + 1]);
    }

    void setTypes(const vector<int32_t>& types) { this->types = types; }

    vector<int32_t> getTypes() { return types; }

    int32_t accept(Compiler::Visitor* visitor) override;
};

} // namespace Parser

#endif // PARSER_PARAMETER_LIST_H
